package com.breadenglish.cms.api.app.gateway.util;

//import org.springframework.security.authentication.AnonymousAuthenticationToken;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.context.SecurityContextHolder;
//import org.springframework.security.core.userdetails.UserDetails;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Util {

    public static String pattern = "yyyy-MM-dd";
    public static SimpleDateFormat format = new SimpleDateFormat(pattern);

    /**
     * 获取登陆用户信息，无需传参数版本
     *
     * @return
     */
   /* public final static UserDetails getUserDetails() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null && !(auth instanceof AnonymousAuthenticationToken)) {
            return (UserDetails) auth.getPrincipal();
        }
        return null;
    }*/

    /**
     * 转换日期
     *
     * @param str
     * @return
     */
    public static Date parseToDate(String str) {
        try {
            Date date = format.parse(str);
            return date;
        } catch (Exception e) {
        }
        return new Date();
    }
}
